<template>
	<scroll-view :scroll-x="lxName==='hd'" class="pz_box cardCont" :class="lxName">
		<view v-for="(item, index) in list" :key="index" class="pz_box_item mb3" @click="tzDetail(item)">
			<image class="pzImg" :src="item.courseImage"></image>
			<view
		    	v-if="showList.indexOf('1') > -1"
				:class="item.flag=='1'?'pz_box_item_box_tag blue':item.courseType=='1'?'pz_box_item_box_tag': 'pz_box_item_box_tag lv'">
				{{item.flag=='1'?'视频课':item.courseType=='1'?'团体课':item.courseType=='3'?'长期课': '私教课'}}
			</view>
			<view v-if="item.courseName || item.courseImage" class="pz_box_item_box">
				<view class="courseName"><image v-if="item.secFlag === '0'"  class="bsImg" :src="imgHost + '/list_ic_miaosha.png'"></image><image v-if="item.secFlag === '1'"  class="bsImg" :src="imgHost + '/list_ic_zhekou.png'"></image>{{item.courseName}}</view>
				<view v-if="showList.indexOf('2') > -1 &&lxName!='jl'" class="bmNum">{{item.joinNum || 0}}人已报名</view>
				<view v-if="lxName=='jl'" class="bmNum flex flex_between">
					<text>{{formatSeconds(item.duration)}}</text>
					<text>{{item.teacherNum}}个教练可预约</text>
				</view>
				<view class="pzFoot flex flex_between">
					<view v-if="showList.indexOf('3') > -1" class="price" :class="item.price&& Number(item.price) >0?'redColor':'green'">
						{{item.price&& Number(item.price) >0?'¥':''}}<text :class="item.price&& Number(item.price) >0?'f32 fwb':'green f28'">{{item.price&& Number(item.price) >0?item.price:'免费'}}</text><text v-if="lxName==='jl' && item.price&& Number(item.price) >0" class="qi c9">起</text>
					</view>
					<view v-if="showList.indexOf('3') == -1" class="price"></view>
					<view class="jl flex flex_between">
						<image v-if="showList.indexOf('5') > -1 && item.teacherImage" :src="item.teacherImage? item.teacherImage : imgHost+'/user.png'"></image>
						<text v-if="showList.indexOf('4') > -1 && item.teacherName" class="limit-1-line">{{item.teacherName}}</text>
					</view>
				</view>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	export default {
		props: {
			lxName: {
				type: String,
				default: 'sx'
			},
			list: {
				type: Array,
				default: () => []
			},
			teacherIds: {
				type: Array,
				default: () => []
			},
			showList: {
				type: Array,
				default: ()=>['1','2','3','4','5']
			},
		},
		methods: {
			jump(url, params, a) {
				this.$app.jump(url, params, a);
			},
			jump2(url, params, a) {
				this.$app.jump2(url, params, a);
			},
			formatSeconds(e) {
			   return this.$app.formatSeconds(e);
			},
			//单张图片预览
			previewImg(imgurl) {
				let _this = this;
				let imgsArray = [];
				imgsArray[0] = imgurl
				uni.previewImage({
					current: 0,
					urls: imgsArray
				});
			},
			tzDetail(item) {
				if (item.flag == '1') {
					this.jump2('/pages/curriculum/detailb?id=', item.courseId)
				} else {
					// this.jump2('/pages/curriculum/detail?id=', item.courseId)
					let teacherIds = [...this.teacherIds]
					let teacherId = encodeURIComponent(JSON.stringify(teacherIds))
					this.jump2('/pages/curriculum/detail?id=', item.courseId + '&teacherId=' + teacherId)
				}
			}
		}

	}
</script>
<style lang="scss" scoped>
	.pz_box {
		.pzImg {
			vertical-align: top;
		}
		.bsImg {
			width: 60rpx;
			height: 32rpx;
			margin-right: 8rpx;
			display: inline-block;
			vertical-align: middle;
			margin-top: -6rpx;
		}
		.pz_box_item {
			width: 100%;
			background: #FFFFFF;
			border-radius: 8rpx;
			position: relative;
			overflow: hidden;

			.pz_box_item_box_tag {
				position: absolute;
				top: 15rpx;
				left: 15rpx;
				padding: 5rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				// background: $phb;
				background: $color;
				border-radius: 8rpx;
				font-size: 22rpx;
				color: #FFFFFF;

				// &.blue {
				// 	background: $blueBg;
				// }

				// &.lv {
				// 	background: linear-gradient(270deg, #6BE599 0%, #14B76D 100%);
				// }
			}

			.courseName {
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #222222;
				line-height: 1;
				margin-bottom: 20rpx;
			}

		}

		.pzFoot {
			align-items: flex-end;
			line-height: 1;
			.price {
				text {
					&.qi {
						font-size: 22rpx;
						font-weight: normal;
						margin-left: 4rpx;
					}
				}
			}

			.jl {
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #666666;
				max-width: 50%;

				image {
					width: 44rpx;
					height: 44rpx;
					border-radius: 50%;
					margin-right: 10rpx;
				}
			}
		}

		&.dt,
		&.sx {
			.pz_box_item {
				// border: 1rpx solid #E5E5E5;

				.pzImg {
					width: 100%;
					height: 388rpx;
				}

				.pz_box_item_box {
					position: static;
					box-sizing: border-box;
					padding: 20rpx;


					.bmNum {
						position: absolute;
						top: 325rpx;
						font-size: 22rpx;
						left: 15rpx;
						line-height: 42rpx;
						background: rgba(0, 0, 0, 0.6);
						border-radius: 22rpx;
						color: #fff;
						padding: 0 10rpx;
					}

				}
			}
		}

		&.sx {
			display: flex;
			flex-wrap: wrap;
			
			&:before {
				clear: both;
				content: '';
				display: block;
			}

			.pz_box_item {
				// border: 1rpx solid #E5E5E5;
				width: 49%;
				float: left;
				box-sizing: border-box;
				margin-right: 2%;

				&:nth-child(2n) {
					margin-right: 0;
				}
				.pzImg {
					height: 188rpx;
				}

				.pz_box_item_box {
					.bmNum {
						top: 126rpx;
					}

					.courseName {
						overflow: hidden;
						height: 80rpx;
						text-overflow: ellipsis;
						display: -webkit-box;
						line-height: 40rpx;
						-webkit-line-clamp: 2;
						/* autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
					}
				}

			}
		}

		&.hd {
			white-space: nowrap;
			display: flex;

			.pz_box_item {
				// border: 1rpx solid #E5E5E5;
				width: 440rpx;
				display: inline-block;
				margin-right: 30rpx;

				&:last-of-type {
					margin-right: 0;
				}

				.pzImg {
					width: 100%;
					height: 247rpx;
				}

				.pz_box_item_box {
					position: static;
					box-sizing: border-box;
					padding: 20rpx;
					background-color: #fff;

					.courseName {
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						line-height: 40rpx;
						-webkit-line-clamp: 1;
						margin-bottom: 15rpx;
						/* autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
					}

					.bmNum {
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						margin-bottom: 10rpx;
					}
				}
			}
		}


		&.zt, &.jl {
			.pz_box_item {
				display: flex;
				justify-content: space-between;
				background: none;

				.pzImg {
					width: 260rpx;
					border-radius: 8rpx;
					flex: none;
					height: 146rpx;
				}

				.pz_box_item_box {
					flex: 1;
					box-sizing: border-box;
					padding-left: 20rpx;
					position: static;

					.courseName {
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						line-height: 1.3;
						-webkit-line-clamp: 2;
						/* autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
					}

					.bmNum {
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						margin-bottom: 10rpx;
					}
				}
			}
		}
		&.zt {
			.pz_box_item {
				background: #FFFFFF;
				box-sizing: border-box;
				padding: 20rpx;
				.pz_box_item_box_tag {
					top: 34rpx;
					left: 34rpx;
				}
			}
		}
	}
	.bmNum {
		line-height: 48rpx;
		height: 48rpx;
	}
</style>